package com.cdinternationalcompany.syhapp.push.oppo

import android.app.Activity
import android.content.Intent
import android.os.Bundle
import android.util.Log
import com.cdinternationalcompany.syhapp.MainActivity
import com.cdinternationalcompany.syhapp.utils.ChannelManager

class OppoPushEntryActivity:Activity() {

    override fun onNewIntent(intent: Intent?) {
        super.onNewIntent(intent)
        Log.d("Push.Oppo","intent -> $intent")
        if (intent != null) {
            val bundle = intent.extras
            if (bundle != null) {
                if (bundle.keySet().contains("jump_target")) {
                    val para = mutableMapOf<String,String>()
                    for (key in bundle.keySet()) {
                        val content = bundle.getString(key)
                        para[key] = content.toString()
                        Log.i("vasdlkjvlsdj", "receive data from push, key = $key, content = $content")
                    }

                    ChannelManager.instance.callFlutter(
                            "PushApi/receiveMessage", para,
                    )
                }
            }
        }

//        val para = mapOf<String,String>()
//        (Pair("token",token),Pair("platform",platform))
//        if (bundle != null) {
//            for (key in bundle.keySet()) {
//                val content = bundle.getString(key)
//                para[key] = content
//                Log.i(MainActivity.TAG, "receive data from push, key = $key, content = $content")
//            }
//        }

    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        Log.d("Push.Oppo","intent -> $intent")
    }
}